package cn.johnyu.service.impl;

import cn.johnyu.service.AuthenPersistenceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@Slf4j
//@Service
public class AuthenPersistenceServiceMemImpl implements AuthenPersistenceService {
    private static final Map<String,String> authenRepo=new HashMap<>();
    @Override
    public Mono<Boolean> save(String token) {
        String rs = authenRepo.put(token, "");
        return Mono.just(true);

    }

    @Override
    public Mono<Boolean> check(String token) {

        return Mono.just(authenRepo.containsKey(token));
    }

    @Override
    public Mono<Boolean> delete(String token) {
        String remove = authenRepo
                .remove(token);
        if(remove!=null){
            return Mono.just(true);
        }
        else{
            return Mono.just(false);
        }
    }
}
